home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / SPX30.ZIP / SPX_DOC.ZIP / SPX_GEO.DOC < prev    next >
Encoding:
Text File  |  1994-06-13  |  5.0 KB  |  155 lines

  1. { SPX Library Version 3.0  Copyright 1993 Scott D. Ramsay }
  2.  
  3.   SPX_GEO is the geomorph "tile map" handling unit.  It allows you to
  4. scroll large maps.  The maps are composed of sprites that are aligned
  5. next to each other like a tile floor.
  6.  
  7. ───────────────────────────────────────────────────────────────────────────
  8. type
  9.   Pmorph = ^Tmorph;
  10.   Tmorph = object
  11.  
  12.  
  13. VARIABLES:
  14.      gosx,gofsy:byte:   Used internally.  Indicates the pixel offset of
  15.                         the map;
  16.      gv_width:          Width of sprites to display. (in tiles amount);
  17.      gv_height:         Height of sprites to display. (in tiles);
  18.      gmx,gmy:           Width and height of geomorph (in tiles);
  19.      gsx,gsy:           Width and height of tile (in pixels);
  20.      hvx,hvy:           Used internally; = gv_width div 2,gv_height div 2;
  21.      smapx,smapy:       Top-left corner region of geomorph;
  22.      yaccum,xaccum:     Used internally; accumlators to draw the tiles
  23.      yinc,xinc:         Used internally; addition accumlators
  24.  
  25.   ---------------------------------------------------
  26.   constructor Tmorph.init(geomx,geomy,six,siy,gvw,gvh,scrx,scry:integer);
  27.      Sets up the object.
  28.  
  29.      GEOMX:     Width of geomorph (in tiles);
  30.      GEOMY:     Height of geomorph (in tiles);
  31.      SIX:       Width of the tiles
  32.      SIY:       Height of the tiles
  33.      GVW:       Width of tiles to display (in tiles);
  34.      GVH:       Height of tiles to display (in tiles);
  35.      SCRX,SCRY: Top-left corner region of geommorph
  36.  
  37.   ---------------------------------------------------
  38.   destructor Tmorph.done; virtual;
  39.  
  40.   Deallocates the object
  41.  
  42.   ---------------------------------------------------
  43.   procedure Tmorph.yaccumulator(inital:boolean;at:integer);virtual;
  44.  
  45.   Used in the drawing loop to increment in the y position
  46.  
  47.   OVERRIDE: Seldom
  48.  
  49.   ---------------------------------------------------
  50.   procedure Tmorph.xaccumulator(inital:boolean;at:integer);virtual;
  51.  
  52.   Used in the drawing loop to increment in the x position
  53.  
  54.   OVERRIDE: Seldom
  55.  
  56.   ---------------------------------------------------
  57.   function Tmorph.geomap(x,y:integer):integer;virtual;
  58.  
  59.   Returns the tile number at the (X,Y) coordinate.
  60.  
  61.     X,Y:  Tile positon of geomorph (in tiles)
  62.  
  63.   OVERRIDE: Always
  64.  
  65.   ---------------------------------------------------
  66.   procedure Tmorph.drawmap(vx,vy:integer);virtual;
  67.  
  68.   Displays the geomorph on the active page.
  69.  
  70.     VX,VY:  Center position area of geomorph to display.
  71.             (in pixels)
  72.  
  73.             VX is usually in the range 0..geomorph_width*sprite_width-1
  74.             VY is usually in the range 0..geomorph_height*sprite_height-1
  75.  
  76.   ---------------------------------------------------
  77.   procedure Tmorph.placegeo(x,y,geonum,cx,cy:integer);virtual;
  78.  
  79.   Called from Tmorph.drawmap. Displays a tile on the screen.
  80.  
  81.     X,Y:     Top-left position of tile to display;
  82.     GEONUM:  Tile number to display
  83.     CX,CY:   width, height counter position of tile
  84.  
  85.   OVERRIDE: Often
  86.  
  87.   Usually your override procedure would look something like:
  88.  
  89.     procedure TMyMorph.placegeo(x,y,geonum,cx,cy:integer);
  90.     begin
  91.       fput(x,y,geo_tiles[geonum]^);
  92.     end;
  93.  
  94.   ---------------------------------------------------
  95.   procedure Tmorph.nogogeo(x,y,cx,cy:integer);virtual;
  96.  
  97.   Called from Tmorph.drawmap.  Is called when a tile is
  98.   out of map range.
  99.  
  100.   ---------------------------------------------------
  101.   procedure Tmorph.pre_map; virtual;
  102.  
  103.   Called before each drawing of the geomorph.
  104.  
  105.   ---------------------------------------------------
  106.   procedure Tmorph.post_map; virtual;
  107.  
  108.   Called after each drawing of the geomorph.
  109.  
  110. ───────────────────────────────────────────────────────────────────────────
  111.  
  112. type
  113.   PHexMorph = ^THexMorph;
  114.   THexMorph = object(Tmorph)
  115.  
  116.   This desendant of Tmorph allows for irregular spacing of the tile map.
  117.  
  118. VARIABLES:
  119.       oddy,oddx:        Sets the (x,y) offset position of the odd columns
  120.       evenx,eveny:      Sets the (x,y) offset position of the even columns
  121.  
  122.       By default the above variables are set to zero. (will function like
  123.        a Tmorph object)
  124.  
  125.  
  126. ───────────────────────────────────────────────────────────────────────────
  127. function loadGMP(f:string;var piclist,map):integer;
  128.  
  129.   Load a .GMP file from disk.
  130.  
  131.   F:        DOS file name of GMP file to load;
  132.   PICLIST:  Array of pointer to hold the tiles;
  133.   MAP:      Array of byte or word to hold the map
  134.  
  135.   Returns the number of tiles in the GMP file.
  136.  
  137.   The example below loads a 100,100 GMP file:
  138.  
  139.   const
  140.     gmx  = 100;
  141.     gmy  = 100;
  142.  
  143.   var
  144.     geo_tiles : array[1..100] of pointer;
  145.     MyMap     : array[0..gmy-1,0..gmx-1] of byte;
  146.     geos      : integer;
  147.  
  148.   begin
  149.     geos := LoadGMP('MyGMP.GMP',geo_tiles,MyMap);
  150.   end;
  151. ───────────────────────────────────────────────────────────────────────────
  152. function loadGMPLib(lib:pSpxLib;f:string;var piclist,map):integer;
  153.  
  154.   Same as loadGMP, loads a GMP file from a SPX library file
  155. ───────────────────────────────────────────────────────────────────────────